package com.wanbatv.wangwangba;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.android.volley.toolbox.ImageLoader;

/**
 * Created by 俞亚楠 on 2015/10/29.
 */
public class ChengzhangrijiVideoFragment extends Fragment {

    private ImageLoader mImageLoader = null;

    public static ChengzhangrijiVideoFragment newInstance(String url, String cover) {
        ChengzhangrijiVideoFragment f = new ChengzhangrijiVideoFragment();
        Bundle arg = new Bundle();
        arg.putString("url", url);
        arg.putString("cover", cover);
        f.setArguments(arg);
        return f;
    }

    public void setImageLoader(ImageLoader imageLoader) {
        mImageLoader = imageLoader;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_chengzhangriji_video, null);
        View btnPause = view.findViewById(R.id.video_status);
        ImageView coverView = (ImageView) view.findViewById(R.id.video_cover);
        btnPause.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle arguments = getArguments();
                Intent intent = new Intent(getActivity(), VideoPlayerActivity.class);
                intent.putExtra("url", arguments.getString("url"));
                getActivity().startActivityForResult(intent, 1000);
            }
        });
        Bundle arguments = getArguments();
        mImageLoader.get(arguments.getString("cover"), ImageLoader.getImageListener(coverView, 0, 0),
                coverView.getWidth(),
                coverView.getHeight(),
                ImageView.ScaleType.CENTER_CROP);
        return view;
    }
}
